home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok24.lha
/
DME
/
SRC
/
source.zoo
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-03
|
26KB
|
983 lines
/*
* MAIN.C
*
* (C)Copyright 1987 by Matthew Dillon, All Rights Reserved.
*
*/
#include "defs.h"
#include <local/deemu.h>
#include <local/ipc.h>
short Deemu[] = {
DMSTRT, 0, 0,
DMNW, 0,10,0,0,0,0,0xFFFF,
'SC','R.', 0, 1,0x0200,
DMEND, 0, 0
};
#define DMNWOFF 4
#define DMSCREEN 17
#define IDCMPFLAGS CLOSEWINDOW|NEWSIZE|RAWKEY|MOUSEBUTTONS|ACTIVEWINDOW|MOUSEMOVE|MENUPICK|GADGETUP|GADGETDOWN
extern SCR *OpenScreen();
extern WIN *OpenWindow();
extern char *menu_cmd();
extern struct Gadget Gadget1;
NW Nw = {
0, 1, 0 , 0 , -1, -1, /* width, height filled in by program */
IDCMPFLAGS,
ACTIVATE|WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|NOCAREREFRESH|RMBTRAP,
&Gadget1,
NULL, (ubyte *)" WAIT ",
NULL, NULL,
94, 47, -1, -1,
WBENCHSCREEN
};
short Sharedrefs;
short Oldtlen = 999; /* Old Title Length */
struct MsgPort *Sharedport;
DISKOBJ *Do;
WBS *Wbs;
SCR *Screen = NULL;
WIN *Win;
RP *Rp;
short Xsize, Ysize; /* font character sizes */
short Rows, Columns; /* character rows/cols available */
short Xbase, Ybase; /* offset pixel base for display */
short XTbase,YTbase; /* used for text display */
short Xpixs, Ypixs; /* actual # X/Y pixels available */
short Mx, My;
ubyte *av[8];
char Quitflag;
char Overide;
char SizeOveride;
char Wdisable = 1; /* Disable icon save */
char MShowTitle, MForceTitle;
short Nwwidth, Nwheight, Nwtopedge, Nwleftedge, Nwtmpwidth, Nwtmpheight;
PORT *IPCPort;
PORT *IPCRPort;
long Mask;
int Enable_Abort;
extern WIN *opensharedwindow();
static char *Ffile;
PROC *proc;
main(mac, mav)
char *mav[];
{
char nf, ni; /* # files on command line */
char notdone; /* for endless loop */
char iawm = 0; /* overide mouse buttons */
char dontwait = 0; /* don't wait for a message */
short i;
short Code;
long origlock;
struct IntuiMessage *gmess = NULL; /* used for gadget handling */
proc = (PROC *)FindTask(NULL);
origlock = CurrentDir(DupLock(proc->pr_CurrentDir));
NewList(&DBase);
#ifndef NO_DO2
NewList(&PBase);
#endif
if (!openlibs(INTUITION_LIB|GRAPHICS_LIB))
exiterr("cannot open intuition or graphics library");
initipc();
InitDeemuNW(Deemu+DMNWOFF, &Nw);
ScreenDepth = (Deemu[DMSCREEN] >> 8);
init_command();
Nwwidth = Nw.Width; /* Parameters for new windows */
Nwheight = Nw.Height;
Nwtopedge = Nw.TopEdge;
Nwleftedge = Nw.LeftEdge;
Enable_Abort= 0; /* disable break */
String = (char *)malloc(1); /* initialize scanf variable */
*String = 0;
if (mac == 0) { /* WORKBENCH STARTUP */
Wdisable = 0; /* allow icon save */
Wbs = (WBS *)mav;
if (!openlibs(ICON_LIB))
exiterr("unable to open icon library");
UnLock(CurrentDir(DupLock(Wbs->sm_ArgList[0].wa_Lock))); /* Tool */
Do = GetDiskObject(Wbs->sm_ArgList[0].wa_Name);
if (Do == NULL)
exiterr("unable to get disk object");
mac = 99;
}
#if AREXX
mountrequest(0);
openrexx(); /* do this after the last possible call to exiterr() */
mountrequest(1);
#endif
resethash();
if (Do) {
ops(Do->do_ToolTypes, 1);
nf = Wbs->sm_NumArgs - 1;
UnLock(CurrentDir(DupLock(Wbs->sm_ArgList[0].wa_Lock)));
} else {
nf = ops(mav+1, 0);
}
for (ni = 0, i = 1; i < mac; ++i) {
register char *str;
register DISKOBJ *dso;
if (Wbs) {
if (i > nf)
break;
str = Wbs->sm_ArgList[i].wa_Name;
UnLock(CurrentDir(DupLock(Wbs->sm_ArgList[i].wa_Lock)));
if (dso = GetDiskObject(Wbs->sm_ArgList[i].wa_Name)) {
ops(dso->do_ToolTypes, 1);
FreeDiskObject(dso);
}
} else {
str = mav[i];
if (*str == '-')
continue;
}
do_newwindow(nf > 1, ni * 11);
++ni;
av[0] = (ubyte *)"newfile";
av[1] = (ubyte *)str;
{
long lock;
struct FileInfoBlock *fib;
lock = Lock(str, SHARED_LOCK);
if(lock) {
fib = malloc(sizeof(struct FileInfoBlock));
Examine(lock,fib);
if(fib->fib_DirEntryType > 0) {
/* CurrentDir(lock); */
UnLock(Ep->dirlock);
Ep->dirlock = lock;
av[1] = (ubyte *) "unnamed";
} else
UnLock(lock);
free(fib);
}
do_edit();
}
MForceTitle = 1;
window_title();
}
if (nf == 0) /* no files to edit */
do_newwindow(nf > 1, ni * 10);
mountrequest(0);
av[0] = NULL;
av[1] = (ubyte *)"s:.edrc";
do_source();
av[0] = NULL;
av[1] = (ubyte *)((Ffile) ? Ffile : ".edrc");
do_source();
mountrequest(1);
{ /* 1.29c */
register ED *ep;
register ED *eb = Ep;
if (eb) {
for (ep = (ED *)eb->Node.mln_Succ; ep->Node.mln_Succ; ep = (ED *)ep->Node.mln_Succ) {
ep->Tabstop = eb->Tabstop;
ep->Margin = eb->Margin;
ep->Insertmode = eb->Insertmode;
ep->IgnoreCase = eb->IgnoreCase;
ep->Wordwrap = eb->Wordwrap;
if (eb->Font) {
ep->Font = eb->Font;
++eb->Font->tf_Accessors;
}
}
}
}
title("DME V1.4 \251Copyright 1988 by Matthew Dillon, All Rights Reserved ");
Mask |= 1 << Win->UserPort->mp_SigBit;
loop:
if (!Ep->iconmode)
text_cursor(1);
for (notdone = 1; !Quitflag && notdone;) {
char mmove = 0;
short mqual;
if (!Ep->iconmode)
window_title();
if (dontwait) {
--dontwait;
} else {
Wait(Mask);
}
/*
* NOTE: due to operation of breakcheck(), the userport signal
* may not be set even if there are messages pending.
*
* NOTE2: CheckPort() requires dres.library, which will be loaded
* if IPCPort exists because the IPC needs it also.
*/
if (IPCPort && CheckPort(IPCPort))
ipchandler();
{
register IMESS *im;
while (im = (IMESS *)GetMsg(Win->UserPort)) {
Msgchk = 1;
Abortcommand = 0;
Code = im->Code;
if (im->IDCMPWindow != Win) {
Overide = 0;
if (Comlinemode)
escapecomlinemode();
text_sync();
MShowTitle = 0;
if (!Ep->iconmode)
window_title();
if (text_switch(im->IDCMPWindow) == 0) {
ReplyMsg(im);
continue;
}
}
Mx = im->MouseX;
My = im->MouseY;
switch(im->Class) {
case GADGETDOWN:
gmess = im;
break;
case GADGETUP:
gmess = NULL;
break;
case NEWSIZE:
if (!Ep->iconmode) {
if (Comlinemode)
escapecomlinemode();
set_window_params();
if (!text_sync())
text_redisplay();
text_cursor(1);
}
break;
case MOUSEBUTTONS:
switch(Code) {
case SELECTDOWN:
case MENUDOWN:
if (Ep->iconmode || iawm) {
uniconify();
break;
}
ReportMouse(-1, Win);
uniconify();
text_cursor(0);
keyctl(NULL, im->Code|0x80, im->Qualifier);
text_cursor(1);
break;
case SELECTUP:
case MENUUP:
ReportMouse(0, Win);
break;
}
break;
case RAWKEY:
if ((im->Code & 0x80) == 0) {
/* Handled in command interpreter.
if (Ep->iconmode) {
uniconify();
break;
}
*/
text_cursor(0);
if(Ep->Replacemode)
multireplace(im);
else
keyctl(im, im->Code, im->Qualifier);
text_cursor(1);
}
break;
case MENUPICK:
{
register char *str = menu_cmd(im);
if (str) {
str = strcpy(malloc(strlen(str)+1), str);
text_cursor(0);
do_command(str);
free(str);
text_cursor(1);
}
}
break;
case CLOSEWINDOW:
if (Comlinemode)
escapecomlinemode();
text_sync();
notdone = 0;
break;
case ACTIVEWINDOW:
if (!Ep->iconmode)
iawm = 1;
break;
case MOUSEMOVE:
mmove = 1;
mqual = im->Qualifier;
break;
}
if (im)
ReplyMsg(im);
if (notdone == 0 || Quitflag) {
dontwait = 2;
goto boom;
}
if (gmess)
break;
}
}
iawm = 0;
if (gmess) {
if (Comlinemode)
escapecomlinemode();
Gad(gmess);
dontwait++;
}
if (mmove) {
uniconify();
mmove = 0;
text_cursor(0);
keyctl(NULL, QMOVE, mqual);
text_cursor(1);
}
closesharedwindow(NULL);
}
boom:
text_sync();
if (Ep->Modified && !Overide) {
uniconify();
Overide = 1;
title("*** File has been modified ***");
Quitflag = 0;
goto loop;
}
SetWindowTitles(Win, "", -1);
#if M2ERR
if(Ep->err_num)
err_quit();
#endif
text_uninit(); /* uninitialize text portion */
closesharedwindow(Win);
if (((ED *)DBase.mlh_Head)->Node.mln_Succ) {
Quitflag = 0;
Win = Ep->Win; /* make arbitrary other window act. */
Rp = Win->RPort;
if (!Ep->iconmode)
set_window_params();
text_load();
MShowTitle = 0;
set_prop();
goto loop;
}
closesharedwindow(NULL);
if (Do)
FreeDiskObject(Do);
#if AREXX
closerexx();
#endif
UnLock(CurrentDir(origlock));
if (IPCPort)
CloseIPC(IPCPort);
if (IPCRPort)
DeletePort(IPCRPort);
if(Screen)
CloseScreen(Screen);
closelibs(-1);
dealloc_hash();
}
ipchandler()
{
register IPCMSG *msg;
register char *ptr;
while (msg = (IPCMSG *)GetMsg(IPCPort)) {
register long error = 0;
if (ptr = (char *)msg->TBuf) { /* Valid msg, */
register ED *ed;
/* For this project */
if (ptr[0] == 0)
ed = Ep;
else if ((ed = finded(ptr, 0)) == NULL)
error = IF_NOTFND;
if (ed) {
if (ed != Ep)
text_switch(ed->Win);
if (!Ep->iconmode)
text_cursor(0);
while (*ptr++); /* Skip Project Name */
do_command(ptr);
}
}
ReplyIPC(msg, NULL, 0, error);
}
}
/*
* If it is possible, create an IPC port for DME. IF_ALLOC specifies that
* incomming static messages should be re-allocated automatically because
* we will be destroying the input buffer for messages we process.
*/
initipc()
{
if (openlibs(DRES_LIB)) {
if (IPCPort = OpenIPC("dme.CMD", IF_ALLOC)) {
Mask |= 1 << IPCPort->mp_SigBit;
IPCRPort = CreatePort(NULL,0);
}
}
}
/*
* IPC appname projname command
*/
void
do_ipc()
{
char *buf;
char buf2[64];
IPCMSG msg;
short len;
if (!IPCPort)
initipc();
if (!IPCPort) {
Abortcommand = 1;
title("dres.library not installed");
return;
}
buf = malloc(len = strlen(av[2])+strlen(av[3])+2);
strcpy(buf, av[2]);
strcpy(buf+strlen(buf)+1, av[3]);
strcpy(buf2, av[1]);
strcat(buf2, ".CMD");
msg.Msg.mn_ReplyPort = IPCRPort;
msg.TBuf = (APTR)buf;
msg.TLen = len;
msg.TFlags = IF_NOCOPY;
DoIPC2(buf2, &msg, ipchandler, IPCPort);
if (msg.RFlags & IF_ERROR) {
if (msg.RFlags & IF_NOAPP)
title("Application not found");
else
title("Remote error");
}
FreeIPC(&msg);
free(buf);
}
do_iconify()
{
text_sync();
if (!Comlinemode)
iconify();
}
do_tomouse()
{
text_position((Mx-Xbase)/Xsize, (My-Ybase)/Ysize);
}
iconify()
{
if (!Ep->iconmode) {
Ep->Winx = Win->LeftEdge;
Ep->Winy = Win->TopEdge;
Ep->Winwidth = Win->Width;
Ep->Winheight = Win->Height;
Nw.Height = 10;
Nw.Width = 20 + 5*8 + strlen(Ep->Name)*8;
Nw.LeftEdge= Ep->IWinx;
Nw.TopEdge = Ep->IWiny;
if (Nw.LeftEdge + Nw.Width > Win->WScreen->Width)
Nw.LeftEdge = Win->WScreen->Width - Nw.Width;
if (Nw.TopEdge + Nw.Height > Win->WScreen->Height)
Nw.TopEdge = Win->WScreen->Height - Nw.Height;
Nw.Title = Ep->Wtitle;
Nw.Flags &= ~(WINDOWSIZING|WINDOWDEPTH|ACTIVATE);
Nw.Flags |= BORDERLESS;
Nw.BlockPen = (Ep->Modified) ? 3 : -1;
sprintf(Ep->Wtitle, "%s ", Ep->Name);
if (Win->Flags & WINDOWACTIVE) /* KTS */
Nw.Flags |= ACTIVATE;
closesharedwindow(Win);
Win = Ep->Win = opensharedwindow(&Nw);
Nw.BlockPen = -1;
Nw.Flags |= WINDOWSIZING|WINDOWDEPTH;
Nw.Flags &= ~BORDERLESS;
Rp = Win->RPort;
}
Ep->iconmode = 1;
}
uniconify()
{
if (Ep->iconmode) {
Ep->IWinx = Win->LeftEdge;
Ep->IWiny = Win->TopEdge;
closesharedwindow(Win);
Nw.LeftEdge = Ep->Winx;
Nw.TopEdge = Ep->Winy;
Nw.Width = Ep->Winwidth;
Nw.Height = Ep->Winheight;
Nw.Title = Ep->Wtitle;
Win = Ep->Win = opensharedwindow(&Nw);
menu_strip(Win);
Rp = Win->RPort;
if (Ep->Font)
SetFont(Rp, Ep->Font);
set_window_params();
if (!text_sync())
text_redisplay();
text_cursor(1);
MShowTitle = 0;
window_title();
}
Ep->iconmode = 0;
set_prop();
}
do_newwindow(makesmall, deltaheight)
{
NS ns;
WIN *win;
int msadj = makesmall;
if(ScreenDepth && !Screen) {
if(ScreenDepth > 4)
ScreenDepth = 4;
bzero(&ns,sizeof(NS));
ns.Width = Nwwidth+Nwleftedge;
ns.Height = Nwheight+Nwtopedge;
ns.Depth = ScreenDepth;
ns.DetailPen = 0;
ns.BlockPen = 1;
if(ns.Height > 282)
ns.ViewModes = HIRES|INTERLACE;
else
ns.ViewModes = HIRES;
ns.Type = CUSTOMSCREEN;
ns.DefaultTitle = (UBYTE *) "DME V1.4";
Screen = OpenScreen(&ns);
}
if (SizeOveride)
msadj = 0;
if (Ep)
text_sync();
Nw.Title = (ubyte *)" OK ";
Nw.Width = (Nwtmpwidth) ? Nwtmpwidth : Nwwidth;
Nw.Height= (Nwtmpheight)? Nwtmpheight: Nwheight;
Nwtmpwidth = Nwtmpheight = 0;
Nw.LeftEdge = Nwleftedge;
Nw.TopEdge = Nwtopedge;
if(ScreenDepth) {
Nw.Type = CUSTOMSCREEN;
Nw.Screen = Screen;
}
if (msadj > 0) { /* deltaheight must be valid */
Nw.TopEdge = deltaheight + 16;
Nw.LeftEdge= 10*8;
Nw.Flags &= ~ACTIVATE;
Nw.Width = 40*8;
Nw.Height= 10*8;
if (Nw.TopEdge + Nw.Height > 200)
Nw.TopEdge = deltaheight = 200 - Nw.Height;
}
win = opensharedwindow(&Nw);
menu_strip(win);
Nw.Flags |= ACTIVATE;
if (win) {
Win = win; /* set new window */
Rp = Win->RPort;
set_window_params();
text_init(); /* initialize */
text_load();
if (makesmall != -1) /* if deltaheight valid */
Ep->IWiny = deltaheight + 16;
}
set_prop();
}
WIN *
TOpenWindow(nw)
NW *nw;
{
WIN *win;
while ((win = OpenWindow(nw)) == NULL) {
if (nw->Width < 50 || nw->Height < 50)
break;
nw->Width -= 10;
nw->Height-= 10;
}
return(win);
}
WIN *
opensharedwindow(nw)
NW *nw;
{
WIN *win;
if (Sharedport)
nw->IDCMPFlags = NULL;
else
nw->IDCMPFlags = IDCMPFLAGS;
win = TOpenWindow(nw);
if (win) {
if (Sharedport) {
win->UserPort = Sharedport;
ModifyIDCMP(win, IDCMPFLAGS);
} else {
Sharedport = win->UserPort;
}
++Sharedrefs;
}
return(win);
}
closesharedwindow(win)
WIN *win;
{
static WIN *wunlink;
register IMESS *im;
char notoktoclosenow = 0;
if (win) {
SetWindowTitles(win, "", -1);
ClearMenuStrip(win);
Forbid();
win->UserPort = NULL;
ModifyIDCMP(win, GADGETUP); /* NEVER occurs */
notoktoclosenow = 1;
Permit();
if (notoktoclosenow) {
win->UserData = (char *)wunlink;
wunlink = win;
} else {
CloseWindow(win);
}
--Sharedrefs;
} else {
if (Sharedrefs == 0 && Sharedport) {
DeletePort(Sharedport);
Sharedport = NULL;
}
for (win = wunlink; win; win = wunlink) {
wunlink = (WIN *)win->UserData;
CloseWindow(win);
}
wunlink = NULL;
}
}
getyn(text)
char *text;
{
int result;
ITEXT *body, *pos, *neg;
body = (ITEXT *)AllocMem(sizeof(ITEXT), 0);
pos = (ITEXT *)AllocMem(sizeof(ITEXT), 0);
neg = (ITEXT *)AllocMem(sizeof(ITEXT), 0);
bzero(body, sizeof(ITEXT));
bzero(pos , sizeof(ITEXT));
bzero(neg , sizeof(ITEXT));
body->BackPen = pos->BackPen = neg->BackPen = 1;
body->DrawMode= pos->DrawMode= neg->DrawMode= AUTODRAWMODE;
body->LeftEdge = 10;
body->TopEdge = 12;
body->IText = (ubyte *)text;
pos->LeftEdge = AUTOLEFTEDGE;
pos->TopEdge = AUTOTOPEDGE;
pos->IText = (ubyte *)"OK";
neg->LeftEdge = AUTOLEFTEDGE;
neg->TopEdge = AUTOTOPEDGE;
neg->IText = (ubyte *)"CANCEL";
result = AutoRequest(Win,body,pos,neg,0,0,320,58);
FreeMem(body, sizeof(ITEXT));
FreeMem(pos , sizeof(ITEXT));
FreeMem(neg , sizeof(ITEXT));
return(result);
}
title(buf)
char *buf;
{
SetWindowTitles(Win, buf, -1);
Oldtlen = 999;
MShowTitle = 3;
}
window_title()
{
register int len, maxlen;
if (memoryfail) {
title(" -- NO MEMORY -- ");
memoryfail = 0;
text_redisplay();
}
if (MForceTitle) {
MShowTitle = 0;
MForceTitle = 0;
}
if (MShowTitle) {
--MShowTitle;
return(0);
}
{
register char *mod;
FONT *oldfont;
mod = (Ep->Modified) ? " (modified)" : " ";
sprintf(Ep->Wtitle, "%3ld/%-3ld %3ld %s%s ", text_lineno(), text_lines(), text_colno()+1, text_name(), mod);
if (!text_imode())
strcat(Ep->Wtitle, "Ovr ");
len = strlen(Ep->Wtitle);
if (len < Columns && Columns < 128) {
bset(Ep->Wtitle+len, Columns - len + 1, ' ');
Ep->Wtitle[Columns + 1] = 0;
}
/*
* Update title
*/
oldfont = Win->RPort->Font;
SetFont(Win->RPort, Win->WScreen->RastPort.Font);
Win->Title = Ep->Wtitle;
SetAPen(Rp, 0);
SetBPen(Rp, 1);
Move(Rp, 30, Win->RPort->Font->tf_Baseline+1);
maxlen = (Win->Width-96)/Win->RPort->Font->tf_XSize;
if (maxlen < 0)
maxlen = 0;
if (len > maxlen)
len = Oldtlen = maxlen;
if (Oldtlen > maxlen)
Oldtlen = maxlen;
Text(Rp, Ep->Wtitle, len); /* No flash */
while (Oldtlen - len >= (int)sizeof(Space)) {
Text(Rp, Space, sizeof(Space));
Oldtlen -= sizeof(Space);
}
if (Oldtlen - len > 0)
Text(Rp, Space, Oldtlen - len);
Oldtlen = len; /* Oldtlen might have been < */
SetAPen(Rp, 1);
SetBPen(Rp, 0);
SetFont(Win->RPort, oldfont);
}
}
set_window_params()
{
Xsize = Rp->Font->tf_XSize;
Ysize = Rp->Font->tf_YSize;
Xbase = Win->BorderLeft;
Ybase = Win->BorderTop;
Xpixs = Win->Width - Win->BorderRight - Xbase;
Ypixs = Win->Height- Win->BorderBottom- Ybase;
Columns = Xpixs / Xsize;
Rows = Ypixs / Ysize;
XTbase = Xbase;
YTbase = Ybase + Rp->Font->tf_Baseline;
set_prop();
}
exiterr(str)
char *str;
{
if (Output()) {
Write(Output(),str,strlen(str));
Write(Output(),"\n",1);
}
exit(1);
}
/*
* Check break by scanning pending messages in the I stream for a ^C.
* Msgchk forces a check, else the check is only made if the signal is
* set in the I stream (the signal is reset).
*/
breakcheck()
{
IMESS *im;
register struct List *list = &Win->UserPort->mp_MsgList;
if (Msgchk || (SetSignal(0,0) & (1<<Win->UserPort->mp_SigBit))) {
Msgchk = 0;
SetSignal(0,1<<Win->UserPort->mp_SigBit);
im = (IMESS *)list->lh_Head;
Forbid();
for (; im != &list->lh_Tail; im = (IMESS *)im->ExecMessage.mn_Node.ln_Succ) {
if (im->Class == RAWKEY && (im->Qualifier & 0xFB) == 0x08 &&
im->Code == CtlC) {
Permit();
SetSignal(SIGBREAKF_CTRL_C,SIGBREAKF_CTRL_C);
return(1);
}
}
Permit();
}
return(0);
}
breakreset()
{
SetSignal(0, SIGBREAKF_CTRL_C);
}
/*
* leftedge n
* topedge n
* width n
* height n
* tmpwidth n
* tmpheight n
*/
void
do_windowparm()
{
int val = atoi(av[1]);
if (av[0][0] == 't' && av[0][1] == 'm') { /* tmpwidth/tmpheight */
if (av[0][3] == 'w')
Nwtmpwidth = val;
if (av[0][3] == 'h')
Nwtmpheight= val;
return;
}
switch(av[0][0]) {
case 'l':
Nwleftedge = val;
break;
case 't':
Nwtopedge = val;
break;
case 'w':
Nwwidth = val;
break;
case 'h':
Nwheight = val;
break;
}
}
/*
* resize cols rows
*/
do_resize()
{
int cols = atoi(av[1]);
int rows = atoi(av[2]);
short width = (cols*Win->RPort->Font->tf_XSize) + Win->BorderLeft + Win->BorderRight;
short height= (rows*Win->RPort->Font->tf_YSize) + Win->BorderTop + Win->BorderBottom;
if (width < 16 || height < 16 ||
width > Win->WScreen->Width - Win->LeftEdge ||
height > Win->WScreen->Height - Win->TopEdge) {
title ("window too big (try moving to upper left corner and retrying)");
return(0);
}
SizeWindow(Win, width - Win->Width, height - Win->Height);
set_prop();
Delay(50*2); /* wait 2 seconds */
}
ops(av, iswb)
register char *av[];
{
register short nonops;
register short i;
register long val;
register char *str;
for (i = nonops = 0; str = av[i]; ++i) {
if (iswb) {
if (strncmp(str, "ARG", 3) == 0) {
while (*str && *str != '-')
++str;
}
}
if (*str == '-') {
val = atoi(str+2);
switch(str[1]) {
case 'f':
Ffile = str+2;
break;
case 'b':
SizeOveride = 1;
break;
case 't':
Nwtopedge = val;
break;
case 'l':
Nwleftedge= val;
break;
case 'w':
SizeOveride = 1;
Nwwidth = val;
break;
case 'h':
SizeOveride = 1;
Nwheight = val;
break;
case 's':
ScreenDepth = val;
break;
}
} else {
++nonops;
}
}
return(nonops);
}